<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/12/9
  Time: 18:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<form action="/demo002/addBook" method="POST" enctype="multipart/form-data">
    书名<input type="text" name="bookName"> <br>
    作者<input type="text" name="bookWriter"> <br>
    类型<input type="text" name="bookType"> <br>
    价格<input type="text" name="bookPrice"> <br>
    出版时间<input type="Date" name="pubDate"> <br>
    封面<input type="file" name="mf" id="imageInput"> ${msg}
    <img src="${book.bookCover}" alt="" class="bookCover" id="bookCover">
    <br>
    <input type="submit" value="修改"></form>
</body>
<script>
    document.getElementById('imageInput').addEventListener('change', function(event) {
        let file = event.target.files[0];
        let reader = new FileReader();
        reader.onload = function(e) {
            document.getElementById('bookCover').src = e.target.result;
        };
        reader.readAsDataURL(file);
    });
</script>
</html>
